import {defineStore} from "pinia";
import {ref} from "vue";
import {reqDictChildrenList, reqDictParentList} from "@/api/index.js";


const useDictStore = defineStore("dictionary", () => {
    const parentList = ref([])
    const pageInfo = ref({})

    async function loadParentList(params) {
        const res = await reqDictParentList(params)
        parentList.value = res.data.records
        pageInfo.value = res.data.pageInfo
    }

    function updateChildrenList(data) {
        childrenList.value = data
    }

    return {parentList, pageInfo, loadParentList}
})

export default useDictStore